package com.netty.socket.gatewayClient;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * Created by Administrator on 2018/9/9/009.
 */
public class GatewayClient {
    public  void satrt(){
        EventLoopGroup loopGroop = new NioEventLoopGroup();

        try {
            Bootstrap bootStrap = new Bootstrap();

            bootStrap.group(loopGroop).channel(NioSocketChannel.class);
            bootStrap.handler(new GatewayClientInitializer());

            ChannelFuture channelFuture = bootStrap.connect("localhost", 8811).sync();
            channelFuture.channel().closeFuture().sync();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            loopGroop.shutdownGracefully();
        }
    }
}
